import request from '@/utils/request'

// 1. 创建 请求 文章接口
export const getArticles = function(params) {
  return request({
    method: 'GET',
    url: '/articles',
    params
  })
}

export const getArticleById = articleId => {
  return request({
    method: 'GET',
    url: '/articles/' + articleId
  })
}

export const addCollect = target => {
  return request({
    method: 'POST',
    url: '/article/collections',
    data: {
      target
    }
  })
}

export const deleteCollect = target => {
  return request({
    method: 'DELETE',
    url: `/article/collections/${target}`
  })
}

export const addLike = articleId => {
  return request({
    method: 'POST',
    url: '/article/likings',
    data: {
      target: articleId
    }
  })
}

export const deleteLike = articleId => {
  return request({
    method: 'DELETE',
    url: `/article/likings/${articleId}`
  })
}
